<?php
/**
 * Created by PhpStorm.
 * User: *!N.J
 * Date: 2021/9/8
 * Time: 9:41
 * QQ:1467572213
 */

namespace app\agent\controller;

use think\facade\Request;
use think\facade\Session;
use \app\agent\model\Withdrawal as Withdrawal_m;

class Withdrawal extends Base
{
    public function index()
    {
        $agent_id = Session::get('agent_id');
        $keyword = Request::get('keyword');
        $list = Withdrawal_m::index($agent_id,$keyword);
        $page = $list->render();
        $this->assign('pages', $page);
        $this->assign('list', $list);
        return $this->fetch();
    }

    public function withdrawal_pass()
    {
        $agent_id = Session::get('agent_id');
        if (Request::isPost()){
            $id = Request::post('id');
            $pass = Withdrawal_m::withdrawal_pass($agent_id,$id);
            switch ($pass)
            {
                case 'success':
                    return ['code'=>1,'msg'=>'已通过'];
                    break;
                case 'error':
                    return ['code'=>0,'msg'=>'系统错误'];
                    break;
            }
        }
    }

    public function withdrawal_refuse()
    {
        $agent_id = Session::get('agent_id');
        if (Request::isPost()){
            $id = Request::post('id');
            $refuse = Withdrawal_m::withdrawal_refuse($agent_id,$id);
            switch ($refuse)
            {
                case 'success':
                    return ['code'=>1,'msg'=>'已拒绝'];
                    break;
                case 'error_money':
                    return ['code'=>0,'msg'=>'返回余额错误'];
                    break;
                case 'error_status':
                    return ['code'=>0,'msg'=>'状态错误'];
                    break;
                case 'error_info':
                    return ['code'=>0,'msg'=>'提现信息错误'];
                    break;
            }
        }
    }
}